<?php 
require_once("inc_security.php");
//check quyen them sua xoa
checkAddEdit("edit");
   $errorMsg = "";
	//Khai bao Bien
	$fs_redirect 							= base64_decode(getValue("url","str","GET",base64_encode("listing.php")));
	$record_id 								= getValue("record_id");
//Call Class generate_form();
	$myform 									= new generate_form();
	//Loai bo chuc nang thay the Tag Html
	

	$myform->add("com_title","com_title",0,0,"",0,translate_text("Vui lòng nhập vào tiêu đề tuyển dụng!"),0,"");
	
	
	
	//Add table
	$myform->addTable($fs_table);
	//Warning Error!
	//Get Action.
	$action	= getValue("action", "str", "POST", "");
	if($action == "execute"){
		$myform->removeHTML(0);
		
		$errorMsg .= $myform->checkdata();
		echo $errorMsg;
        $myform->add("com_content","com_content", 0, 0, 0, 0,"", 0,"");
		if($errorMsg == ""){
			$db_ex 	= new db_execute_return();
			$last_id = $db_ex->db_execute($myform->generate_update_SQL($id_field, $record_id));
		//echo $myform->generate_update_SQL($id_field, $record_id);
		//	$iParent = getValue("cat_parent_id","int","POST");
        //if($iParent > 0){
        //$db_ex = new db_execute("UPDATE categories_multi SET cat_has_child = 1 WHERE cat_id = " . $iParent);
        //}
			redirect("listing.php");
		//	exit();
		}
	}
	//add form for javacheck
	$myform->addFormname("add_new");
	$myform->evaluate();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php echo $load_header?>
<?php  
$myform->checkjavascript();
$errorMsg .= $myform->strErrorField;

//lay du lieu cua record can sua doi
$db_data 	= new db_query("SELECT * FROM " . $fs_table . " WHERE " . $id_field . " = " . $record_id);
if($row 		= mysql_fetch_assoc($db_data->result)){
	foreach($row as $key=>$value){
		if($key!='lang_id' && $key!='admin_id') $$key = $value;
	}
}else{
		exit();
}
?>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<?php  /*------------------------------------------------------------------------------------------------*/ ?>
<?php echo template_top(translate_text("Edit_city"))?>
<?php  /*------------------------------------------------------------------------------------------------*/ ?>
	<p align="center" style="padding-left:10px;">
	<?php 
	$form = new form();
	$form->create_form("add", $_SERVER["REQUEST_URI"], "post", "multipart/form-data",'onsubmit="validateForm(); return false;"');
	$form->create_table();
	?>
	
	<?php echo $form->text("Tiêu đề thông tin", "com_title", "com_title", $com_title, "Tiêu đề tuyển dụng", 1, 240, "", 255, "", "", "")?>
	<?php echo $form->close_table()?>
	<?php echo $form->wysiwyg("Nội dung thông tin", "com_content", $com_content, "../../resource/wysiwyg_editor/","80%",450)?>	
    <?php echo $form->create_table("2")?>
	<?php echo $form->button("submit" . $form->ec . "reset", "submit" . $form->ec . "reset", "submit" . $form->ec . "reset", "Cập nhật" . $form->ec . "Làm lại", "Cập nhật" . $form->ec . "Làm lại", '' . $form->ec . '', "");?>
	<?php echo $form->hidden("action", "action", "execute", "");?>
	
	<?php 
	$form->close_table();
	$form->close_form();
	unset($form);
	?>
	</p>
<?php echo template_bottom() ?>
<?php  /*------------------------------------------------------------------------------------------------*/ ?>
</body>
</html>